package 华为OD机试真题2023.基础题;


import java.io.File;
import java.io.FileNotFoundException;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class HJ11_获得完美走位 {
    public static void main(String[] args) throws FileNotFoundException {
        Scanner in = new Scanner(new File("src/main/java/华为OD机试真题2023/基础题/input/11.txt"));
        char[] cArray = in.nextLine().toCharArray();
        int len = cArray.length;
        Map<Character, Integer> map = new HashMap<>();
        map.put('A', 0);
        map.put('D', 0);
        map.put('W', 0);
        map.put('S', 0);
        for (char a : cArray) {
            map.put(a, map.get(a) + 1);
        }
        int total = 0;
        int target = len / 4;
        for (char s : map.keySet()) {
            total += Math.abs(map.get(s) - target);
        }
        System.out.println(total / 2);
    }
}
